package com.aletto.general_store.ui.popup;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.aletto.general_store.R;
import com.aletto.general_store.data.model.OrderItem;
import com.aletto.general_store.presenters.OrderRaiseArbitrationTask;
import com.lxj.xpopup.core.CenterPopupView;

import java.math.BigDecimal;

public class OrderRefundPopup extends CenterPopupView {

    private OrderItem item;

    public OrderRefundPopup(@NonNull Context context) {
        super(context);
    }

    public OrderRefundPopup(@NonNull Context context, OrderItem item) {
        super(context);
        this.item = item;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_order_refund;
    }

    @Override
    protected void onCreate() {
        super.onCreate();

        BigDecimal price = new BigDecimal(item.getPrice()).multiply(new BigDecimal(item.getNum()));

        TextView tv_price = findViewById(R.id.tv_price);
        tv_price.setText("退款金额：" + price + " USDT");

        findViewById(R.id.button_cancel).setOnClickListener(v -> dismiss());

        findViewById(R.id.button_confirm).setOnClickListener(v -> {
            dismiss();
            new OrderRaiseArbitrationTask(item.getBtc_order_id()).execute();
        });
    }

}
